<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/template/template.xhtml">

	<ui:define name="styleAndScript"></ui:define>
	<ui:define name="center_content">
		<h:form prependId="false" id="main_form">
			<div class="style1">
				<h:panelGrid columns="6" columnClasses="column1,column2,column1,column2,column1,column2">
					<h:outputText value="资源编号：" />
					<p:inputText value="#{resourceBean.queryMap['code']}" />
					<h:outputText value="资源类型：" />
					<h:selectOneMenu value="#{resourceBean.queryMap['type']}"
						styleClass="ui-inputfield ui-widget ui-state-default ui-corner-all">
						<f:selectItem itemLabel="#{msgs.select}" itemValue=""/>
						<f:selectItems value="#{appInfo.getDictsByRootcode(resourceBean.rootType)}" var="dict"
							itemLabel="#{dict.name}" itemValue="#{dict.value}"/>
					</h:selectOneMenu>
		        </h:panelGrid>
		        <div>
		        	<p:commandButton value="#{msgs.btnQuery}" icon="#{comm.queryClass}" 
		        		action="#{resourceBean.searchTreetable}" update=":main_form:res_tree_table"/>
		        	<p:commandButton value="#{msgs.btnReset}" icon="#{comm.resetClass}" type="reset"/>
		        </div>
			</div>
			
			<p:contextMenu for="res_tree_table">
				<p:menuitem value="#{msgs.btnQuery}" icon="#{comm.queryClass}" 
					update=":resource_edit_dialog" oncomplete="resource_edit_var.show();">
					<f:setPropertyActionListener target="#{resourceBean.model}" value="#{comm.m_q}" />
					<f:setPropertyActionListener target="#{resourceBean.instance}" value="#{resourceBean.selectedRes.data}" />
					<f:setPropertyActionListener target="#{resourceBean.summary}" value="查询资源信息：" />
				</p:menuitem>
				<p:menuitem value="#{msgs.btnEdit}" icon="#{comm.editClass}"
					update=":resource_edit_dialog" oncomplete="resource_edit_var.show();">
					<f:setPropertyActionListener target="#{resourceBean.model}" value="#{comm.m_m}" />
					<f:setPropertyActionListener target="#{resourceBean.instance}" value="#{resourceBean.selectedRes.data}" />
					<f:setPropertyActionListener target="#{resourceBean.summary}" value="编辑资源信息：" />
				</p:menuitem>
				<p:menuitem value="分配资源角色" icon="#{comm.allotClass}" action="#{resourceBean.getResRoles}"
					update=":role_resource_edit_form" oncomplete="role_resource_edit_var.show();">
					<f:setPropertyActionListener target="#{resourceBean.instance}" value="#{resourceBean.selectedRes.data}" />
				</p:menuitem>
			</p:contextMenu>
	
			<p:treeTable id="res_tree_table" value="#{resourceBean.root}" var="node"
				selectionMode="single" selection="#{resourceBean.selectedRes}">
				<f:facet name="header">资源列表
					<div
						style="text-align: right; position: relative; margin: -13px -5px 0px 0px; vertical-align: middle">
						<p:commandButton value="#{msgs.btnNew}" icon="#{comm.newClass}"
							actionListener="#{resourceBean.initAddResource}"
							oncomplete="resource_edit_var.show();"
							update=":resource_edit_dialog">
							<f:setPropertyActionListener target="#{resourceBean.model}" value="#{comm.m_a}"/>
							<f:setPropertyActionListener target="#{resourceBean.summary}" value="资源信息添加：" />
						</p:commandButton>
					</div>
				</f:facet>
				<p:column headerText="资源名称" style="width: 20%;">#{node.name}</p:column>
				<p:column headerText="资源编码" style="width: 10%;">#{node.code}</p:column>
				<p:column headerText="资源路径">#{node.url}</p:column>
				<p:column headerText="#{msgs.valid}" style="width: 5%;">#{node.status == 1 ? msgs.valid_y : msgs.valid_n}</p:column>
				<p:column headerText="资源备注" style="width: 20%;">#{node.remarks}</p:column>
				<p:column headerText="操作" style="width: 12%;">
					<p:commandButton title="#{msgs.btnQuery}" icon="#{comm.queryClass}" 
						update=":resource_edit_dialog" oncomplete="resource_edit_var.show();">
						<f:setPropertyActionListener target="#{resourceBean.model}" value="#{comm.m_q}" />
						<f:setPropertyActionListener target="#{resourceBean.instance}" value="#{node}" />
						<f:setPropertyActionListener target="#{resourceBean.summary}" value="查询资源信息：" />
					</p:commandButton>
					<p:commandButton title="#{msgs.btnEdit}" icon="#{comm.editClass}"
						update=":resource_edit_dialog" oncomplete="resource_edit_var.show();">
						<f:setPropertyActionListener target="#{resourceBean.model}" value="#{comm.m_m}" />
						<f:setPropertyActionListener target="#{resourceBean.instance}" value="#{node}" />
						<f:setPropertyActionListener target="#{resourceBean.summary}" value="编辑资源信息：" />
					</p:commandButton>
					<p:commandButton title="分配资源角色" icon="#{comm.allotClass}" action="#{resourceBean.getResRoles}"
						update=":role_resource_edit_form" oncomplete="role_resource_edit_var.show();">
						<f:setPropertyActionListener target="#{resourceBean.instance}" value="#{node}" />
					</p:commandButton>
				</p:column>
			</p:treeTable>
		</h:form>
	</ui:define>
	<ui:define name="edit_content">
		<ui:include src="/faces/common/resource/resource_edit.xhtml"/>
		<ui:include src="/faces/common/resource/role_resource_edit.xhtml"/>
	</ui:define>
</ui:composition>